
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>文字2</title>
</head>
<body >
<canvas id="canvas" style="display: block;margin: 0 auto;border: 1px solid #aaa">
    您的浏览器不支持canvas
</canvas>
<script>
    var canvas=document.getElementById("canvas");
    var context=canvas.getContext("2d");

    var originalMoveTo= CanvasRenderingContext2D.prototype.moveTo;
    CanvasRenderingContext2D.prototype.lastMoveToLoc={};
    CanvasRenderingContext2D.prototype.moveTo=function(x,y){
        originalMoveTo.apply(context,[x,y]);
        this.lastMoveToLoc.x=x;
        this.lastMoveToLoc.y=y;
    }
    CanvasRenderingContext2D.prototype.fillStar=function (r,R,rot){
        this.beginPath();
        for(var i=0;i<5;i++){
            this.lineTo(Math.cos((18+i*72-rot)/180*Math.PI)*R+this.lastMoveToLoc.x,
                    -Math.sin((18+i*72-rot)/180*Math.PI)*R+this.lastMoveToLoc.y);
            this.lineTo(Math.cos((54+i*72-rot)/180*Math.PI)*r+this.lastMoveToLoc.x,
                    -Math.sin((54+i*72-rot)/180*Math.PI)*r+this.lastMoveToLoc.y);
        }
        this.closePath();
        this.fill();
    };
    window.onload=function(){
        canvas.width=800;
        canvas.height=800;

        context.fillStyle="#058";
        context.moveTo(400,400);
        context.fillStar(150,300,30);
    }

</script>
</body>
</html>